#include <bits/stdc++.h>
using namespace std;
#define int long long

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    auto b = a;
    sort(b.begin(), b.end());
    for(int i = 0; i < n; i++) {
        if((b[i] & 1) != (a[i] & 1)) {
            cout << "NO" << endl;
            return;
        }
    }
    cout << "YES" << endl;
}

signed main() {
    int t;
    cin >> t;
    while(t--) solve();
    return 0;
}